<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@taglib prefix="mvc" uri="http://www.springframework.org/tags/form" %>
<%@taglib prefix="fmt" uri="http://www.springframework.org/tags" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <title>立项列表（学院科研室主任）</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=10,chrome=1">
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0">
    <link rel="stylesheet" type="text/css" href="/lib/layui/layui/css/layui.css"/>
    <script type="text/javascript" src="/js/news/jquery-1.9.1.js"></script>
    <script src="/js/base/base.js" type="text/javascript" charset="utf-8"></script>
    <script src="../../js/jquery/jquery.cookie.js"></script>
    <script src="/lib/jQuery-File-Upload-master/jquery.ui.widget.js" type="text/javascript" charset="utf-8"></script>
    <script src="/lib/jQuery-File-Upload-master/jquery.iframe-transport.js" type="text/javascript" charset="utf-8"></script>
    <script src="/lib/jQuery-File-Upload-master/jquery.fileupload.js" type="text/javascript" charset="utf-8"></script>
    <script type="text/javascript" src="/js/common/fileupload.js"></script>
    <script type="text/javascript" src="/lib/layui/layui/layui.js"></script>
    <script type="text/javascript" src="/lib/layui/layui/layui.all.js"></script>
</head>
<style>
    .mbox {
        padding: 8px
    }

    .item img {
        height: 40px;
    }

    .btn {
        height: 30px;
    }

    .btn button {
        float: right;
    }

    .information {
        background: #e8f4fc;
        height: 30px;
        line-height: 30px;
    }
    .layui-form-label{
        width: 77px;
    }
    .layui-layer-content{
        line-height: 70px;
        text-align: center;
    }
</style>
<body>
<div class="mbox">
    <div class="item">
        <img src="../img/yeji.png" alt="" style="margin: 0 5px 0 20px;"> <span
            style="font-size: 22px;display: inline-block;vertical-align: middle;">立项列表（学院科研室主任）</span>
    </div>
    <hr class="layui-bg-blue">
    <div class="btn">
        <button type="button" class="layui-btn layui-btn-sm" style="background: #2b7fe0"><i
                class="layui-icon layui-icon-upload-drag" style="background: #2b7fe0"></i>导出Excel
        </button>
        <button type="button" class="layui-btn layui-btn-sm"  style="background: #2b7fe0;margin-right: 20px"><i
                class="layui-icon layui-icon-addition" style="vertical-align: inherit"></i>查询
        </button>
    </div>
    <table class="layui-hide" id="test" lay-filter="test"></table>
</div>
</body>
</html>
<script type="text/html" id="barDemo">
    <a class="layui-btn layui-btn-xs" lay-event="CancellationProject">取消立项</a>
</script>
<script>

    layui.use(['table', 'form', 'laydate','upload'], function () {
        var table = layui.table,
            form = layui.form,
            laydate = layui.laydate,
            upload = layui.upload;
        table.render({
            elem: '#test'
            , url: '/Recognize/getProjectList'
            ,where:{
                trType:1,
                trStatus:2
            }
            , toolbar: '#toolbarDemo' //开启头部工具栏，并为其绑定左侧模板
            , defaultToolbar: ['filter', 'exports', 'print', { //自定义头部工具栏右侧图标。如无需自定义，去除该参数即可
                title: '提示'
                , layEvent: 'LAYTABLE_TIPS'
                , icon: 'layui-icon-tips'
            }]
            , defaultToolbar: ['']
            , title: '用户数据表'
            , cols: [[
                {type: 'checkbox', fixed: 'left'}
                , {field: 'topicName', title: '项目名称',templet:function(d){
                        return d.rpmTopic.topicName
                    }}
                , {field: 'planName', title: '申报计划名称',templet:function(d){
                        return d.rpmPlan.planName
                    }}
                , {field: 'name', title: '项目成员',templet:function(d){
                        var rpmSignatures = d.rpmTopic.rpmSignatures;
                        var nameId = ''
                        if(rpmSignatures != undefined){
                            for(var i=0;i<rpmSignatures.length;i++){
                                if(rpmSignatures[i].userName != undefined && rpmSignatures[i].userName != ''){
                                    nameId += rpmSignatures[i].userName + ',';
                                }
                            }
                            return nameId
                        }
                        return '';
                    }}
                , { title: '负责人',templet:function(d){
                        return d.rpmTopic.userName;
                    }}
                , { title: '专家1 评分',templet:function(d){
                        var scoreList = d.rpmTopic.scoreList;
                        if (scoreList != undefined && scoreList.length > 0 && scoreList[0] != undefined){
                            return scoreList[0].rsScore;
                        }
                        return '';
                    }}
                , { title: '专家1 意见',templet:function(d){
                        var scoreList = d.rpmTopic.scoreList;

                        if (scoreList != undefined && scoreList.length > 0 && scoreList[0] != undefined){
                            return scoreList[0].remarks;
                        }
                        return '';
                    }}
                , { title: '专家2 评分',templet:function(d){
                        var scoreList = d.rpmTopic.scoreList;

                        if (scoreList != undefined && scoreList.length > 0 && scoreList[1] != undefined){
                            return scoreList[1].rsScore;
                        }
                        return '';
                    }}
                , { title: '专家2 意见',templet:function(d){
                        var scoreList = d.rpmTopic.scoreList;

                        if (scoreList != undefined && scoreList.length > 0 && scoreList[1] != undefined){
                            return scoreList[1].remarks;
                        }
                        return '';
                    }}
                , { title: '专家3 评分',templet:function(d){
                        var scoreList = d.rpmTopic.scoreList;

                        if (scoreList != undefined && scoreList.length > 0 && scoreList[2] != undefined){
                            return scoreList[2].rsScore;
                        }
                        return '';
                    }}
                , { title: '专家3 意见',templet:function(d){
                        var scoreList = d.rpmTopic.scoreList;

                        if (scoreList != undefined && scoreList.length > 0 && scoreList[2] != undefined){
                            return scoreList[2].remarks;
                        }
                        return '';
                    }}
                , { title: '专家4 评分',templet:function(d){
                        var scoreList = d.rpmTopic.scoreList;

                        if (scoreList != undefined && scoreList.length > 0 && scoreList[3] != undefined){
                            return scoreList[3].rsScore;
                        }
                        return '';
                    }}
                , { title: '专家4 意见',templet:function(d){
                        var scoreList = d.rpmTopic.scoreList;

                        if (scoreList != undefined && scoreList.length > 0 && scoreList[3] != undefined){
                            return scoreList[3].remarks;
                        }
                        return '';
                    }}
                , { title: '平均分',templet:function(d){
                        var avg = d.rpmTopic.avg;
                        if (avg != undefined){
                            return avg;
                        }
                        return '';
                    }}
                , {field: 'type', title: '操作', toolbar: '#barDemo'}
            ]]
            ,parseData:function(res){
                return {
                    "code":0, //解析接口状态
                    "data": res.object //解析数据列表
                };
            }
            // , page: true
        })

        //监听行工具事件
        table.on('tool(test)', function(obj){
            var data = obj.data;
            console.log(data)
            if(obj.event === 'CancellationProject'){
                layer.open({
                    type: 1,
                    title: '基本信息',
                    btn: ['确定', '取消'],
                    area: ['300px', '170px'],
                    content:'<div>' +
                        '<p >确定取消立项吗？</p>' +
                        '</div>',
                    yes:function(index){
                        $.ajax({
                            url: '/Recognize/updateReMark',
                            type: 'post',
                            data:{
                                trId:data.trId,
                                trStatus:1
                            },
                            success: function () {
                                layer.close(index);
                                // layer.alert('取消完成！', {icon: 1})
                                table.reload('test');
                            }
                        })


                    }
                })
            }
        });
    });
</script>